package mrms.api.web.interceptors;

import mrms.api.entity.UserEntity;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lenchu
 * @date 2019/01/31
 */
public class AdminPermissionInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        UserEntity user = (UserEntity) request.getAttribute("user");
        if (user.getPermission() >= 80) {
            return true;
        }
        return false;
    }
}
